<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<meta name="renderer" content="webkit" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<title>系统后台</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
</head>
<div th:include="shared/css"></div>
<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		<!-- Panel Other -->
		<div class="ibox float-e-margins">
			<div class="ibox-content">
				<div class="row row-lg">
					<div class="col-sm-12">
						<div class="row">
							<div class="col-md-6">
								<div class="col-sm-12">
								<div class="row">
								<div class="col-md-3">
									<label>用户手机</label> 
									<input type="text" class="form-control m-b" id="userMobile" placeholder="请输入" /> 
								</div>
								<div class="col-md-3">
									<button class="btn btn-primary" type="button" onclick="tableRefresh('/getWebUserList')" style="margin-top: 23px;">搜索</button>
									<button class="btn btn-primary" type="button" onclick="openPage('add','')" style="margin-top: 23px;">新增</button>
								</div>
								<div class="col-md-3">
								</div>
								</div>
								</div>
							</div>
							<div class="hr-line-dashed" style="clear: both;"></div>
						</div>
					</div>
					
					<div class="col-sm-12">
						<!-- Example Events -->
						<div class="example-wrap">
							<table id="table" data-mobile-responsive="true"
								data-toggle="table" data-url="/getWebUserList"
								data-data-type="json" data-side-pagination="server"
								data-pagination="true" data-query-params="queryParams"
								data-page-list="[5, 10, 20, 50, 100, 200]"
								data-page-size="10"
								>
								<thead>
									<tr>
										<th data-field="userId" data-align="center" data-visible="false">账户Id</th>
										<th data-field="userName" data-width="10%" data-align="center">姓名</th>
										<th data-field="companyName" data-width="10%" data-align="center">公司名</th>
										<th data-field="phoneNum" data-width="10%" data-align="center">手机号码</th>
										<th data-field="isAdmin" data-width="5%" data-align="center" data-formatter="formatterLock">是否为管理员</th>
										<th data-align="center" data-width="5%" data-formatter='formatterFun'>操作</th>
									</tr>
								</thead>
							</table>
						</div>
						<!-- End Example Events -->
					</div>
				</div>
			</div>
		</div>
		<!-- End Panel Other -->
	</div>
	<div th:include="shared/js"></div>
	<script type="text/javascript" th:inline="javascript">
		var table = $("#table");
		/*查询条件*/
		function queryParams(params) {
			params.phoneNum = $("#userMobile").val();
			return params;
		}
		/**刷新*/
		function tableRefresh(dataUrl) {
			table.bootstrapTable('refresh', {
				url : dataUrl
			});
		}
		
		function formatterLock(value, row, index){
			if(value==1){
				return "是";
			}else{
				return "否";
			}
		}
		
		function formatterFun(value, row, index) {
			var id = row.userId;
				return '<div style=" justify-content:center; display:flex;"><button  class="btn btn-success" style="margin:0px 5px;" type="button" onclick="openPage(\'update\','
				+'\''+id+'\')"><i class="fa fa-paste"></i>详情</button></p></div>';
		}
		
		function lockStatus(id,isLock) {
			var param = {
				"id":id,
				"isLock":isLock
			}
			$.post("/hs/webuser/lockStatus", param,function(data){
				if(data.status==10001){
					var page=table.bootstrapTable('getOptions').pageNumber;
					table.bootstrapTable('refresh', {
						url : "/hs/webuser/getWebUserList",
						pageNumber : page
					});
				}else{
					swal("操作失败");
				}
			});
		}
		
		function openPage(action,userId){
			if(action=='add'){
				openAddPage('用户信息', '70%', '95%', '/addUser', '/getWebUserList');
			}else{
				openAddPage('用户信息', '70%', '95%', '/updateEtUser?userId='+userId, '/getWebUserList');
			}
			
			
		}
	</script>
</body>

</html>